import React, { Component } from 'react';
import { connect } from 'dva';
import { message, Modal, Pagination, Popconfirm, Button, Row, Col, List } from 'antd';
import styles from './../Users.css';
import moment from 'moment';
import Factory from '../../factory';
import * as datetime from '../../../utils/datetime'
import dataEditCreate from '../../addons/DataEdit'
import dataTableCreate from '../../addons/DataTable'
import * as compDiviService from '../../../services/AccountDivi';
import numeral from 'numeral';
const renderNumber = (num) => {
    let value = ''
    if (num) {
        value = numeral(num).format('0,0.00')
    }
    return value
};
const daoName = "COMP_CM_BIZ_FEE_SUM_M";
const ButtonGroup = Button.Group;
const columns = [
    { title: '交易日期', width: 110, sorter: true, key: 'JYRQ', caption: "JYRQ", render: data => datetime.format(data.JYRQ, "yyyy-MM-dd"), dispaly: true, filter: true },
    { title: '中收科目号', width: 130, sorter: true, dataIndex: 'ITNO', key: 'ITNO', dispaly: true, filter: true },
    { title: '中收科目', width: 280, sorter: true, dataIndex: 'ACNM', key: 'ACNM', dispaly: true, filter: true },
    { title: '费用产品名称', width: 150, sorter: true, dataIndex: 'CPMC', key: 'CPMC', dispaly: true, filter: true },
    { title: '收费种类名称', width: 200, sorter: true, dataIndex: 'SFZLMC', key: 'SFZLMC', dispaly: true, filter: true },
    { title: '客户名称', width: 300, sorter: true, dataIndex: 'CUNM', key: 'CUNM', dispaly: true, filter: true },
    { title: '金额', width: 120, sorter: true, render: data => renderNumber(data.ACTL_CHARGE_AMT), key: 'ACTL_CHARGE_AMT', dispaly: true, filter: true },
    // { title: '工号1', width: 150, sorter: true, dataIndex: 'EMNO1', key: 'EMNO1', dispaly: true, filter: true },
    { title: '姓名1', width: 150, sorter: true, dataIndex: 'EMNM1', key: 'EMNM1', dispaly: true, filter: true },
    { title: '部门1', width: 150, sorter: true, dataIndex: 'UTNM1', key: 'UTNM1', dispaly: true, filter: true },
    { title: '分配金额1', width: 120, sorter: true, render: data => renderNumber(data.DSVL1), key: 'DSVL1', dispaly: true, filter: true },
    // { title: '工号2', width: 150, sorter: true, dataIndex: 'EMNO2', key: 'EMNO2', dispaly: true, filter: true },
    { title: '姓名2', width: 150, sorter: true, dataIndex: 'EMNM2', key: 'EMNM2', dispaly: true, filter: true },
    { title: '部门2', width: 150, sorter: true, dataIndex: 'UTNM2', key: 'UTNM2', dispaly: true, filter: true },
    { title: '分配金额2', width: 120, sorter: true, render: data => renderNumber(data.DSVL2), key: 'DSVL2', dispaly: true, filter: true },
    // { title: '工号3', width: 150, sorter: true, dataIndex: 'EMNO3', key: 'EMNO3', dispaly: true, filter: true },
    { title: '姓名3', width: 150, sorter: true, dataIndex: 'EMNM3', key: 'EMNM3', dispaly: true, filter: true },
    { title: '部门3', width: 150, sorter: true, dataIndex: 'UTNM3', key: 'UTNM3', dispaly: true, filter: true },
    { title: '分配金额3', width: 120, sorter: true, render: data => renderNumber(data.DSVL3), key: 'DSVL3', dispaly: true, filter: true },
    // { title: '工号4', width: 150, sorter: true, dataIndex: 'EMNO4', key: 'EMNO4', dispaly: true, filter: true },
    { title: '姓名4', width: 150, sorter: true, dataIndex: 'EMNM4', key: 'EMNM4', dispaly: true, filter: true },
    { title: '部门4', width: 150, sorter: true, dataIndex: 'UTNM4', key: 'UTNM4', dispaly: true, filter: true },
    { title: '分配金额4', width: 120, sorter: true, render: data => renderNumber(data.DSVL4), key: 'DSVL4', dispaly: true, filter: true },
    // { title: '工号5', width: 150, sorter: true, dataIndex: 'EMNO5', key: 'EMNO5', dispaly: true, filter: true },
    { title: '姓名5', width: 150, sorter: true, dataIndex: 'EMNM5', key: 'EMNM5', dispaly: true, filter: true },
    { title: '部门5', width: 150, sorter: true, dataIndex: 'UTNM5', key: 'UTNM5', dispaly: true, filter: true },
    { title: '分配金额5', width: 120, sorter: true, render: data => renderNumber(data.DSVL5), key: 'DSVL5', dispaly: true, filter: true },
    // { title: '工号6', width: 150, sorter: true, dataIndex: 'EMNO6', key: 'EMNO6', dispaly: true, filter: true },
    { title: '姓名6', width: 150, sorter: true, dataIndex: 'EMNM6', key: 'EMNM6', dispaly: true, filter: true },
    { title: '部门6', width: 150, sorter: true, dataIndex: 'UTNM6', key: 'UTNM6', dispaly: true, filter: true },
    { title: '分配金额6', width: 120, sorter: true, render: data => renderNumber(data.DSVL6), key: 'DSVL6', dispaly: true, filter: true },
    // { title: '工号7', width: 150, sorter: true, dataIndex: 'EMNO7', key: 'EMNO7', dispaly: true, filter: true },
    { title: '姓名7', width: 150, sorter: true, dataIndex: 'EMNM7', key: 'EMNM7', dispaly: true, filter: true },
    { title: '部门7', width: 150, sorter: true, dataIndex: 'UTNM7', key: 'UTNM7', dispaly: true, filter: true },
    { title: '分配金额7', width: 120, sorter: true, render: data => renderNumber(data.DSVL7), key: 'DSVL7', dispaly: true, filter: true },
    // { title: '工号8', width: 150, sorter: true, dataIndex: 'EMNO8', key: 'EMNO8', dispaly: true, filter: true },
    { title: '姓名8', width: 150, sorter: true, dataIndex: 'EMNM8', key: 'EMNM8', dispaly: true, filter: true },
    { title: '部门8', width: 150, sorter: true, dataIndex: 'UTNM8', key: 'UTNM8', dispaly: true, filter: true },
    { title: '分配金额8', width: 120, sorter: true, render: data => renderNumber(data.DSVL8), key: 'DSVL8', dispaly: true, filter: true },
    // { title: '工号9', width: 150, sorter: true, dataIndex: 'EMNO9', key: 'EMNO9', dispaly: true, filter: true },
    { title: '姓名9', width: 150, sorter: true, dataIndex: 'EMNM9', key: 'EMNM9', dispaly: true, filter: true },
    { title: '部门9', width: 150, sorter: true, dataIndex: 'UTNM9', key: 'UTNM9', dispaly: true, filter: true },
    { title: '分配金额9', width: 120, sorter: true, render: data => renderNumber(data.DSVL9), key: 'DSVL9', dispaly: true, filter: true },
    // { title: '工号10', width: 150, sorter: true, dataIndex: 'EMNO10', key: 'EMNO10', dispaly: true, filter: true },
    { title: '姓名10', width: 150, sorter: true, dataIndex: 'EMNM10', key: 'EMNM10', dispaly: true, filter: true },
    { title: '部门10', width: 150, sorter: true, dataIndex: 'UTNM10', key: 'UTNM10', dispaly: true, filter: true },
    { title: '分配金额10', width: 120, sorter: true, render: data => renderNumber(data.DSVL10), key: 'DSVL10', dispaly: true, filter: true },
];
const controls = [
    { name: 'JYRQ', required: true, type: 'date', label: '交易日期', dataType: "date", grid: 12 / 24 },
    { name: 'ITNO', required: true, type: 'text', label: '中收科目号', grid: 12 / 24 },
    { name: 'ACNM', required: true, type: 'text', label: '中收科目', grid: 12 / 24 },
    { name: 'CUNM', required: true, type: 'text', label: '客户名称', grid: 12 / 24 },
    { name: "ACTL_CHARGE_AMT", required: true, type: 'number', label: '中收金额', dataType: "number", grid: 12 / 24 },
    { name: "CPMC", required: true, type: 'text', label: '费用产品名称', grid: 12 / 24 },
    { name: "SFZLMC", required: true, type: 'text', label: '收费种类名称', grid: 12 / 24 },
    { name: "EMNO1", required: true, type: 'text', label: '工号1', grid: 12 / 24 },
    { name: "EMNM1", required: true, type: 'text', label: '姓名1', grid: 12 / 24 },
    { name: "UTNM1", required: true, type: 'text', label: '部门1', grid: 12 / 24 },
    { name: "DSVL1", required: true, type: 'number', label: '金额1', dataType: "number", grid: 12 / 24 },
    { name: "EMNO2", required: false, type: 'text', label: '工号2', grid: 12 / 24 },
    { name: "EMNM2", required: false, type: 'text', label: '姓名2', grid: 12 / 24 },
    { name: "UTNM2", required: false, type: 'text', label: '部门2', grid: 12 / 24 },
    { name: "DSVL2", required: false, type: 'number', label: '金额2', dataType: "number", grid: 12 / 24 },
    { name: "EMNO3", required: false, type: 'text', label: '工号3', grid: 12 / 24 },
    { name: "EMNM3", required: false, type: 'text', label: '姓名3', grid: 12 / 24 },
    { name: "UTNM3", required: false, type: 'text', label: '部门3', grid: 12 / 24 },
    { name: "DSVL3", required: false, type: 'number', label: '金额3', dataType: "number", grid: 12 / 24 },
    { name: "EMNO4", required: false, type: 'text', label: '工号4', grid: 12 / 24 },
    { name: "EMNM4", required: false, type: 'text', label: '姓名4', grid: 12 / 24 },
    { name: "UTNM4", required: false, type: 'text', label: '部门4', grid: 12 / 24 },
    { name: "DSVL4", required: false, type: 'number', label: '金额4', dataType: "number", grid: 12 / 24 },
    { name: "EMNO5", required: false, type: 'text', label: '工号5', grid: 12 / 24 },
    { name: "EMNM5", required: false, type: 'text', label: '姓名5', grid: 12 / 24 },
    { name: "UTNM5", required: false, type: 'text', label: '部门5', grid: 12 / 24 },
    { name: "DSVL5", required: false, type: 'number', label: '金额5', dataType: "number", grid: 12 / 24 },
    { name: "EMNO6", required: false, type: 'text', label: '工号6', grid: 12 / 24 },
    { name: "EMNM6", required: false, type: 'text', label: '姓名6', grid: 12 / 24 },
    { name: "UTNM6", required: false, type: 'text', label: '部门6', grid: 12 / 24 },
    { name: "DSVL6", required: false, type: 'number', label: '金额6', dataType: "number", grid: 12 / 24 },
    { name: "EMNO7", required: false, type: 'text', label: '工号7', grid: 12 / 24 },
    { name: "EMNM7", required: false, type: 'text', label: '姓名7', grid: 12 / 24 },
    { name: "UTNM7", required: false, type: 'text', label: '部门7', grid: 12 / 24 },
    { name: "DSVL7", required: false, type: 'number', label: '金额7', dataType: "number", grid: 12 / 24 },
    { name: "EMNO8", required: false, type: 'text', label: '工号8', grid: 12 / 24 },
    { name: "EMNM8", required: false, type: 'text', label: '姓名8', grid: 12 / 24 },
    { name: "UTNM8", required: false, type: 'text', label: '部门8', grid: 12 / 24 },
    { name: "DSVL8", required: false, type: 'number', label: '金额8', dataType: "number", grid: 12 / 24 },
    { name: "EMNO9", required: false, type: 'text', label: '工号9', grid: 12 / 24 },
    { name: "EMNM9", required: false, type: 'text', label: '姓名9', grid: 12 / 24 },
    { name: "UTNM9", required: false, type: 'text', label: '部门9', grid: 12 / 24 },
    { name: "DSVL9", required: false, type: 'number', label: '金额9', dataType: "number", grid: 12 / 24 },
    { name: "EMNO10", required: false, type: 'text', label: '工号10', grid: 12 / 24 },
    { name: "EMNM10", required: false, type: 'text', label: '姓名10', grid: 12 / 24 },
    { name: "UTNM10", required: false, type: 'text', label: '部门10', grid: 12 / 24 },
    { name: "DSVL10", required: false, type: 'number', label: '金额10', dataType: "number", grid: 12 / 24 },
];
const controlsEdit = [
    { name: 'CUNM', type: 'text', isDisabled: true, label: '客户名称', grid: 24 / 24, layout: { labelSpan: 3, wrapperSpan: 20 } },
    { name: "CPMC", label: "费用产品", type: "text", isDisabled: true, dataType: "string", grid: 24 / 24, layout: { labelSpan: 3, wrapperSpan: 20 } },
    { name: "SFZLMC", label: "收费种类", type: "text", isDisabled: true, dataType: "string", grid: 24 / 24, layout: { labelSpan: 3, wrapperSpan: 20 } },
    { name: "ITNO", label: "科目号", type: "text", isDisabled: true, dataType: "string", grid: 24 / 24, layout: { labelSpan: 3, wrapperSpan: 20 } },
    { name: "ACNM", label: "科目名称", type: "text", isDisabled: true, dataType: "string", grid: 24 / 24, layout: { labelSpan: 3, wrapperSpan: 20 } },
    { name: "JYRQ", label: "交易日期", type: "date", isDisabled: true, dataType: "date", grid: 12 / 24 },
    { name: "ACTL_CHARGE_AMT", label: "中收金额", isDisabled: true, type: "text", dataType: "string", grid: 12 / 24 },
    // {
    //     name: "dsty", label: "认定方式", required: true, type: "radio-group", dataType: "number",
    //     data: [{ value: '0', label: '金额(元)' }, { value: '1', label: '占比(%)' }], grid: 24 / 24, layout: { labelSpan: 8, wrapperSpan: 13 }
    // },
    {
        name: "YG1", label: "员工1", type: "search", grid: 12 / 24, required: true,
        fetch: {
            daoName: "UserSel", searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "No"
        },
        dataType: "string", placeholder: '请输入工号或名称...'
    },
    { name: "ZB1", label: "占比(%)1", required: true, type: "number", dataType: "number", grid: 12 / 24, placeholder: '请输入占比(%)...' },
    {
        name: "YG2", label: "员工2", type: "search", grid: 12 / 24, required: false,
        fetch: {
            daoName: "UserSel", searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "No"
        },
        dataType: "string", placeholder: '请输入工号或名称...'
    },
    { name: "ZB2", label: "占比(%)2", type: "number", dataType: "number", grid: 12 / 24, placeholder: '请输入占比(%)...' },
    {
        name: "YG3", label: "员工3", type: "search", grid: 12 / 24, required: false,
        fetch: {
            daoName: "UserSel", searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "No"
        },
        dataType: "string", placeholder: '请输入工号或名称...'
    },
    { name: "ZB3", label: "占比(%)3", type: "number", dataType: "number", grid: 12 / 24, placeholder: '请输入占比(%)...' },
    {
        name: "YG4", label: "员工4", type: "search", grid: 12 / 24, required: false,
        fetch: {
            daoName: "UserSel", searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "No"
        },
        dataType: "string", placeholder: '请输入工号或名称...'
    },
    { name: "ZB4", label: "占比(%)4", type: "number", dataType: "number", grid: 12 / 24, placeholder: '请输入占比(%)...' },
    {
        name: "YG5", label: "员工5", type: "search", grid: 12 / 24, required: false,
        fetch: {
            daoName: "UserSel", searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "No"
        },
        dataType: "string", placeholder: '请输入工号或名称...'
    },
    { name: "ZB5", label: "占比(%)5", type: "number", dataType: "number", grid: 12 / 24, placeholder: '请输入占比(%)...' },
    // {
    //     name: "EMNO6", label: "员工6", type: "search", grid: 12 / 24, required: false,
    //     fetch: {
    //         daoName: "UserSel", searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "No"
    //     },
    //     dataType: "string", placeholder: '请输入工号或名称...'
    // },
    // { name: "DSVL6", label: "认定值6", type: "number", dataType: "number", grid: 12 / 24 },
    // {
    //     name: "EMNO7", label: "员工7", type: "search", grid: 12 / 24, required: false,
    //     fetch: {
    //         daoName: "UserSel", searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "No"
    //     },
    //     dataType: "string", placeholder: '请输入工号或名称...'
    // },
    // { name: "DSVL7", label: "认定值7", type: "number", dataType: "number", grid: 12 / 24 },
    // {
    //     name: "EMNO8", label: "员工8", type: "search", grid: 12 / 24, required: false,
    //     fetch: {
    //         daoName: "UserSel", searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "No"
    //     },
    //     dataType: "string", placeholder: '请输入工号或名称...'
    // },
    // { name: "DSVL8", label: "认定值8", type: "number", dataType: "number", grid: 12 / 24 },
    // {
    //     name: "EMNO9", label: "员工9", type: "search", grid: 12 / 24, required: false,
    //     fetch: {
    //         daoName: "UserSel", searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "No"
    //     },
    //     dataType: "string", placeholder: '请输入工号或名称...'
    // },
    // { name: "DSVL9", label: "认定值9", type: "number", dataType: "number", grid: 12 / 24 },
    // {
    //     name: "EMNO10", label: "员工10", type: "search", grid: 12 / 24, required: false,
    //     fetch: {
    //         daoName: "UserSel", searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "No"
    //     },
    //     dataType: "string", placeholder: '请输入工号或名称...'
    // },
    // { name: "DSVL10", label: "认定值10", type: "number", dataType: "number", grid: 12 / 24 },
];
const controlsEdit2 = [
    { name: "ITNO", label: "科目号", type: "text", isDisabled: true, dataType: "string", grid: 24 / 24, layout: { labelSpan: 3, wrapperSpan: 20 } },
    { name: "ACNM", label: "科目名称", type: "text", isDisabled: true, dataType: "string", grid: 24 / 24, layout: { labelSpan: 3, wrapperSpan: 20 } },
    { name: "CPMC", label: "费用产品", type: "text", isDisabled: true, dataType: "string", grid: 24 / 24, layout: { labelSpan: 3, wrapperSpan: 20 } },
    { name: "SFZLMC", label: "收费种类", type: "text", isDisabled: true, dataType: "string", grid: 24 / 24, layout: { labelSpan: 3, wrapperSpan: 20 } },
    { name: "JYRQ", label: "交易日期", type: "date", isDisabled: true, dataType: "date", grid: 12 / 24 },
    { name: "ACTL_CHARGE_AMT", label: "中收金额", isDisabled: true, type: "text", dataType: "string", grid: 12 / 24 },
    // {
    //     name: "XGFS", label: "修改方式", required: true, type: "radio-group", dataType: "number",
    //     data: [{ value: '1', label: '修改并认定' }, { value: '2', label: '只修改户名' }], grid: 24 / 24, layout: { labelSpan: 8, wrapperSpan: 13 }
    // },

    { name: 'CUNM', type: 'text', label: '客户名称', grid: 24 / 24, layout: { labelSpan: 3, wrapperSpan: 20 } },

];

const controlsEdit3 = [
    { name: "ITNO", label: "科目号", type: "text", isDisabled: true, dataType: "string", grid: 24 / 24, layout: { labelSpan: 3, wrapperSpan: 20 } },
    { name: "ACNM", label: "科目名称", type: "text", isDisabled: true, dataType: "string", grid: 24 / 24, layout: { labelSpan: 3, wrapperSpan: 20 } },
    { name: "CPMC", label: "费用产品", type: "text", isDisabled: true, dataType: "string", grid: 24 / 24, layout: { labelSpan: 3, wrapperSpan: 20 } },
    { name: "SFZLMC", label: "收费种类", type: "text", isDisabled: true, dataType: "string", grid: 24 / 24, layout: { labelSpan: 3, wrapperSpan: 20 } },
    { name: "JYRQ", label: "交易日期", type: "date", isDisabled: true, dataType: "date", grid: 12 / 24 },
    { name: "ACTL_CHARGE_AMT", label: "中收金额", isDisabled: true, type: "text", dataType: "string", grid: 12 / 24 },
    // {
    //     name: "XGFS", label: "修改方式", required: true, type: "radio-group", dataType: "number",
    //     data: [{ value: '1', label: '修改并认定' }, { value: '2', label: '只修改户名' }], grid: 24 / 24, layout: { labelSpan: 8, wrapperSpan: 13 }
    // },
    {
        name: "ISXZ", label: "是否当年新增", required: true,
        data: [
            { value: '1', label: '是' },
            { value: '0', label: '否' }
        ],
        grid: 24 / 24, type: "select"
    },

];
const EditFrom = dataEditCreate(daoName);
const DataTable = dataTableCreate(daoName);
class MinOper_DGForm extends Component {
    constructor(props) {
        super(props);
        this.state = {
            dataChange: false,
            diviList: [],
            seachData: {},
            showEdit1: false,
            showEdit2: false,
            showEdit3: false
        };
    }
    componentWillReceiveProps(nextProps) {
        nextProps.selectedRowKeys.map(key => {
            for (let i = 0; i < nextProps.list.length; i++) {
                if (nextProps.list[i]["ID"] === key) {
                    this.state.diviList[0] = { ...nextProps.list[i] };
                    break;
                }
            }
        })
    }
    componentDidMount() {
        this.props.dispatch({
            type: `${daoName}/setKeyName`,
            payload: { keyName: "JLID", permID: this.props.permID }
        });
        let sort = {
            field: 'JYRQ',
            order: 'descend'
        }
        let whereItems = [];
        let WhereCauses = [];
        whereItems.push({
            FieldName: "JYRQ",
            Operator: "=",
            FieldValues: "1900-01-01"
        })
        WhereCauses.push({
            WhereItems: whereItems,
            RelationSign: "AND"
        })
        let seeks = WhereCauses
        this.props.dispatch({
            type: `${daoName}/fetch`,
            payload: { daoName, page: 1, pageSize: 20, seeks, sorter: sort }
        });
        this.loadOptionData();
    }
    loadOptionData() {
        let options = []
        controls.map(c => {
            if (c.fetch) {
                let f = c.fetch;
                if (c.type === 'cascader-select') {
                    f.isCascader = true;
                }
                if (c.type !== 'search') {
                    options.push(f);
                }
            }
        })
        if (daoName && options.length > 0) {
            this.props.dispatch({ type: `${daoName}/fetchOptions`, payload: { options } });
        }
    }
    showModelHandler(k) {
        let key = null
        const len = this.props.selectedRowKeys.length;
        if (len === 0) {
            message.info('请选择要认定的行！', 5);
            return;
        }
        if (k === 1) {
            this.setState({ showEdit1: true, showEdit2: false, showEdit3: false })
        } else if (k === 2) {
            this.setState({ showEdit1: false, showEdit2: false, showEdit3: false })
        } else if (k === 3) {
            this.setState({ showEdit1: false, showEdit2: false, showEdit3: true })
        }
        key = this.props.selectedRowKeys[len - 1]
        this.props.dispatch({
            type: `${daoName}/openEdit`,
            payload: { key }
        });
    }
    edidOkHandler() {
        const form = this.refs.paraForm1.getForm()
        form.validateFields((err, values) => {
            if (!err) {
                controlsEdit.map((c, i) => {
                    if (c.type === 'cascader-select') {
                        let vs = values[c.name];
                        if (vs.length > 0) {
                            values[c.name] = vs[vs.length - 1];
                        } else {
                            values[c.name] = null;
                        }
                    }
                    if (c.dataType === "number") {
                        if (!values[c.name] || values[c.name] === "" || values[c.name] === "0") {
                            values[c.name] = null
                        } else {
                            values[c.name] = Number(values[c.name])
                        }
                    } else if (c.dataType === "date" || c.dataType === "datetime") {
                        let date = !values[c.name] ? null : new Date(values[c.name])
                        values[c.name] = !values[c.name] ? null : new Date(date.getFullYear(), date.getMonth(), date.getDate(), 8, 0, 0)
                    } else {
                        values[c.name] = values[c.name] === undefined ? null : values[c.name]
                    }
                    if (c.multiple || c.type === 'checkbox-group') {
                        values[c.name] = values[c.name].join(',');
                    }
                })
                const record = this.props.record
                values.JLID = record.JLID
                const jlid = values.JLID
                const cunm = values.CUNM
                // const xgfs = values.XGFS
                compDiviService.Xghm({ jlid, cunm }
                ).then(function (data) {
                    if (data === 'OK') {
                        message.success('客户修改成功！')
                        this.showTableHandler()
                    } else {
                        message.error('客户修改失败！客户名称在系统中不存在！')
                        return;
                    }
                }.bind(this)).catch(function (ex) {
                    console.log('请求出错', ex)
                });
            }
        });
    };
    edidOkHandler2() {
        const form = this.refs.paraForm2.getForm()
        form.validateFields((err, values) => {
            if (!err) {
                controlsEdit.map((c, i) => {
                    if (c.type === 'cascader-select') {
                        let vs = values[c.name];
                        if (vs.length > 0) {
                            values[c.name] = vs[vs.length - 1];
                        } else {
                            values[c.name] = null;
                        }
                    }
                    if (c.dataType === "number") {
                        if (!values[c.name] || values[c.name] === "" || values[c.name] === "0") {
                            values[c.name] = null
                        } else {
                            values[c.name] = Number(values[c.name])
                        }
                    } else if (c.dataType === "date" || c.dataType === "datetime") {
                        let date = !values[c.name] ? null : new Date(values[c.name])
                        values[c.name] = !values[c.name] ? null : new Date(date.getFullYear(), date.getMonth(), date.getDate(), 8, 0, 0)
                    } else {
                        values[c.name] = values[c.name] === undefined ? null : values[c.name]
                    }
                    if (c.multiple || c.type === 'checkbox-group') {
                        values[c.name] = values[c.name].join(',');
                    }
                })
                let dsvlSum = Number(values.ZB1) + Number(values.ZB2) + Number(values.ZB3) + Number(values.ZB4) + Number(values.ZB5)
                if (dsvlSum !== 100) {
                    message.error('占比必须为100%');
                    return;
                }
                const record = this.props.record
                values.JLID = record.JLID
                const jlid = values.JLID
                const yg1 = values.YG1
                const yg2 = values.YG2
                const yg3 = values.YG3
                const yg4 = values.YG4
                const yg5 = values.YG5
                const zb1 = Number(values.ZB1)
                const zb2 = Number(values.ZB2)
                const zb3 = Number(values.ZB3)
                const zb4 = Number(values.ZB4)
                const zb5 = Number(values.ZB5)

                compDiviService.Xgyg({ jlid, yg1, yg2, yg3, yg4, yg5, zb1, zb2, zb3, zb4, zb5 }
                ).then(function (data) {
                    if (data === 'OK') {
                        message.success('员工认定成功！')
                        this.showTableHandler()
                    } else {
                        message.error('员工认定失败！')
                        return;
                    }
                }.bind(this)).catch(function (ex) {
                    console.log('请求出错', ex)
                });
            }
        });
    };
    edidOkHandler3() {
        const form = this.refs.paraForm1.getForm()
        form.validateFields((err, values) => {
            if (!err) {
                controlsEdit.map((c, i) => {
                    if (c.type === 'cascader-select') {
                        let vs = values[c.name];
                        if (vs.length > 0) {
                            values[c.name] = vs[vs.length - 1];
                        } else {
                            values[c.name] = null;
                        }
                    }
                    if (c.dataType === "number") {
                        if (!values[c.name] || values[c.name] === "" || values[c.name] === "0") {
                            values[c.name] = null
                        } else {
                            values[c.name] = Number(values[c.name])
                        }
                    } else if (c.dataType === "date" || c.dataType === "datetime") {
                        let date = !values[c.name] ? null : new Date(values[c.name])
                        values[c.name] = !values[c.name] ? null : new Date(date.getFullYear(), date.getMonth(), date.getDate(), 8, 0, 0)
                    } else {
                        values[c.name] = values[c.name] === undefined ? null : values[c.name]
                    }
                    if (c.multiple || c.type === 'checkbox-group') {
                        values[c.name] = values[c.name].join(',');
                    }
                })
                const record = this.props.record
                values.JLID = record.JLID
                const jlid = values.JLID
                const isxz = values.ISXZ
                // const xgfs = values.XGFSisxz
                compDiviService.SetIsxz({ jlid, isxz }
                ).then(function (data) {
                    if (data === 'OK') {
                        message.success('设置成功！')
                        this.showTableHandler()
                    } else {
                        message.error('设置失败！')
                        return;
                    }
                }.bind(this)).catch(function (ex) {
                    console.log('请求出错', ex)
                });
            }
        });
    };
    hideEditHandler(key) {
        if (key === 1) {
            const form = this.refs.paraForm1.getForm();
            form.resetFields();
        } else if (key === 2) {
            const form2 = this.refs.paraForm2.getForm();
            form2.resetFields();
        }else if (key === 3) {
            const form3 = this.refs.paraForm3.getForm();
            form3.resetFields();
        }
        // if (this.state.dataChange) {
        //   this.props.dispatch({
        //     type: `${daoName}/reload`,
        //     payload: { daoName },
        //   });
        //   this.state.dataChange = false;
        // }
        // this.props.showEdit = false
        this.setState({ showEdit1: false, showEdit2: false, showEdit3: false })
        // this.props.dispatch({
        //   type: `${daoName}/hideEdit`
        // });
    };
    showTableHandler() {
        let { KSRQ, JSRQ, JYRQ } = '';
        let seeks = [];
        const form = this.refs.MinOper_DGForm.getForm()
        form.validateFields((err, values) => {
            if (!err) {
                if (values.JYRQ !== undefined) {
                    JYRQ = values.JYRQ
                    let td1 = new Date(values.JYRQ[0]);
                    let month1 = td1.getMonth() + 1;
                    KSRQ = td1.getFullYear() + '-' + month1 + '-' + td1.getDate()
                    let td2 = new Date(values.JYRQ[1]);
                    let month2 = td2.getMonth() + 1;
                    JSRQ = td2.getFullYear() + '-' + month2 + '-' + td2.getDate()
                } else {
                    JYRQ = ""
                    KSRQ = ""
                    JSRQ = ""
                }
            }
        })
        const { cmDate } = this.props
        if (new Date(KSRQ) > new Date(cmDate) || new Date(JSRQ) > new Date(cmDate)) {
            message.error(`查询失败，当前数仓日期为【${datetime.format(cmDate, "yyyy-MM-dd")}】`)
            return
        }
        let whereItems = [];
        let WhereCauses = [];
        whereItems.push(
            {
                FieldName: "JYRQ",
                Operator: ">=",
                FieldValues: KSRQ
            },
            {
                FieldName: "JYRQ",
                Operator: "<=",
                FieldValues: JSRQ
            })
        WhereCauses.push({
            WhereItems: whereItems,
            RelationSign: "AND"
        })
        if (whereItems.length !== 0)
            seeks = WhereCauses;
        else
            seeks = [];

        let sort = {
            field: 'JLID',
            order: 'descend'
        }
        this.props.dispatch({
            type: `${daoName}/fetch`,
            payload: { daoName, page: 1, pageSize: 20, seeks, sorter: sort }
        });
    }
    seachHandler(data) {
        this.state.seachData = data;
    }
    xghm() {
        const len = this.props.selectedRowKeys.length
        if (len <= 0) {
            message.error("请选择要修改的数据行！")
            return
        }
        let cunm = ''
        const key = this.props.selectedRowKeys
        const form = this.refs.MinOper_DGForm.getForm()
        form.validateFields((err, values) => {
            if (!err) {
                cunm = values.CUNM
            }
        });
        const jlid = this.state.recordDivi.JLID
        Modal.confirm({
            title: '提示',
            content: `你确认要修改客户名称为【${cunm}】吗？`,
            okText: '确定',
            cancelText: '取消',
            onOk: () => {
                compDiviService.Xghm({ jlid, cunm }
                ).then(function (data) {
                    if (data === 'OK') {
                        message.success('客户修改成功！')
                        this.showTableHandler()
                        const form = this.refs.MinOper_DGForm.getForm();
                        form.resetFields();
                    } else {
                        message.error('客户修改失败！客户名称在系统中不存在！')
                        return;
                    }
                }.bind(this)).catch(function (ex) {
                    console.log('请求出错', ex)
                });
            }
        });
    }
    selectedRow(data) {
        this.state.selectData = data[0]
        const recordDivi = { DSVL: data[0].ACTL_CHARGE_AMT, JLID: data[0].JLID }
        this.state.recordDivi = recordDivi
    }
    render() {
        let { showEdit, record, offsetHeight, permID, popedomTypes } = this.props
        const controlsCx = [
            { name: 'JYRQ', required: false, type: 'range-date', label: '交易日期', grid: 8 / 24 },
            {
                name: 'button', required: false, type: 'button-group', grid: 2 / 24, layout: { labelSpan: 7, wrapperSpan: 16 }, data: [
                    { value: '1', label: '查询', onClick: this.showTableHandler.bind(this) }]
            },
            {
                name: 'button', required: false, type: 'button-group', grid: 6 / 24, data: [
                    { value: '1', label: '修改户名', onClick: this.showModelHandler.bind(this, 1) },
                    { value: '2', label: '员工认定', onClick: this.showModelHandler.bind(this, 2) },
                    { value: '3', label: '设置是否当年新增', onClick: this.showModelHandler.bind(this, 3) }
                ]
            },
        ]
        if (record.XGFS == null || record.XGFS === undefined) {
            record.XGFS = 1
        }
        record.XGFS = '' + record.XGFS
        return (
            <div className={styles.normal} style={{ background: '#fff', marginTop: -16, padding: '5px 5px' }}>
                <div>
                    <div className={styles.create} style={{ paddingBottom: '-16px' }}>
                        <EditFrom ref="MinOper_DGForm" daoName={daoName} controls={controlsCx} record={record} clearItemMargin={true} />
                    </div>
                    <Modal title="修改户名认定" width={700} visible={this.state.showEdit1} onOk={this.edidOkHandler.bind(this)} onCancel={this.hideEditHandler.bind(this, 1)} maskClosable={false}
                        footer={[
                            <Button key="close" type="ghost" onClick={this.hideEditHandler.bind(this, 1)}>关闭</Button>,
                            <Button key="submit" type="primary" onClick={this.edidOkHandler.bind(this)}>保存</Button>
                        ]}
                    >
                        <EditFrom ref="paraForm1" daoName={daoName} controls={controlsEdit2} record={record} />
                    </Modal>
                    <Modal title="中收员工认定" width={700} visible={this.state.showEdit2} onOk={this.edidOkHandler2.bind(this)} onCancel={this.hideEditHandler.bind(this, 2)} maskClosable={false}
                        footer={[
                            <Button key="close" type="ghost" onClick={this.hideEditHandler.bind(this, 2)}>关闭</Button>,
                            <Button key="submit" type="primary" onClick={this.edidOkHandler2.bind(this)}>保存</Button>
                        ]}
                    >
                        <EditFrom ref="paraForm2" daoName={daoName} controls={controlsEdit} record={record} />
                    </Modal>

                    <Modal title="中收存量增量认定" width={700} visible={this.state.showEdit3} onOk={this.edidOkHandler3.bind(this)} onCancel={this.hideEditHandler.bind(this, 3)} maskClosable={false}
                        footer={[
                            <Button key="close" type="ghost" onClick={this.hideEditHandler.bind(this, 3)}>关闭</Button>,
                            <Button key="submit" type="primary" onClick={this.edidOkHandler3.bind(this)}>保存</Button>
                        ]}
                    >
                        <EditFrom ref="paraForm3" daoName={daoName} controls={controlsEdit3} record={record} />
                    </Modal>

                    <DataTable ref="userTable" daoName={daoName} columns={columns} controls={controls} permID={permID} onSelectChange={this.selectedRow.bind(this)} />
                </div>
            </div>
        )
    }
}

function mapStateToProps(state) {
    const { showEdit, record, selectedRowKeys, list, keyName } = state.COMP_CM_BIZ_FEE_SUM_M;
    const { offsetHeight, userID, orgID, pOrgID, popedomTypes, cmDate } = state.menus
    return {
        userID,
        orgID,
        pOrgID,
        popedomTypes,
        showEdit,
        selectedRowKeys,
        list,
        keyName,
        offsetHeight,
        record,
        cmDate
    }
}
MinOper_DGForm = connect(mapStateToProps)(MinOper_DGForm)
export default MinOper_DGForm;

let render = (props) => React.createElement(MinOper_DGForm, props);
let f = new Factory()
f.set("MinOper_DGForm", render)
